<template>
	<view></view>
</template>

<script>
	export default {
		data() {
			return {
				url: ''
			}
		},
		methods: {
			back() {
				if (this.$store.state.vuex_token === '') {
					this.$u.route({type: 'redirectTo', url: 'pages/users/sign-in'})
				} else {
					this.$u.route({type: 'tab', url: 'pages/home/home'})
				}
			}
		},
		onLoad(option) {
			const _currentWebview = this.$mp.page.$getAppWebview()
			let _wv = plus.webview.create("", "other-webview", {
				plusrequire:"none", //禁止远程网页使用plus的API，有些使用mui制作的网页可能会监听plus.key，造成关闭页面混乱，可以通过这种方式禁止
				'uni-app': 'none', //不加载uni-app渲染层框架，避免样式冲突
				top: uni.getSystemInfoSync().statusBarHeight + 44,
				bottom: 0,
				popGesture: 'none',
				kernel: "WKWebview"
			})
			uni.setNavigationBarTitle({
			    title: option.title
			});
			_currentWebview.setStyle({"popGesture": "none"})
			_wv.loadURL(option.url)
			_currentWebview.append(_wv)
		},
		onBackPress(options) {
			const otherWebview = this.$scope.$getAppWebview().children()[0];
			otherWebview.canBack((e) => {
				if (e.canBack) {
					otherWebview.back()
				} else {
					this.back()
				}
			});
			return true
		}
	}
</script>
